home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / tds / convsrc / catcomp2msg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-01  |  1.4 KB  |  75 lines

  1. /* CatComp2Msg.c */
  2.  
  3. #include <exec/types.h>
  4. #include <dos/stdio.h>
  5. #include <clib/dos_protos.h>
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. static UBYTE version[] = "$VER: CatComp2Msg 1.00 (28.01.94)";
  11.  
  12. struct ErrorMsg {
  13.   BOOL warn;
  14.   LONG row,col;
  15.   UBYTE fileName[256];
  16.   UBYTE errStr[256];
  17. };
  18.  
  19.  
  20. void 
  21. PrintMsg(struct ErrorMsg *msg)
  22. {
  23.   printf("<%s> %d %c <%s>\n",msg->fileName,msg->row,(msg->warn ? 'W' : 'E'),msg->errStr);
  24. }
  25.  
  26.  
  27. /* CatComp 39.5
  28. ERROR: '/' expected
  29.        file 'foo.ct' line 1 column 17
  30. WARNING: original string for token <name>
  31.        file 'foo.ct' line 10 column 27
  32. */
  33.  
  34. BOOL
  35. ConvertMsg(struct ErrorMsg *msg)
  36. {
  37. UBYTE line[256];
  38. BOOL found;
  39.  
  40.   found = FALSE;
  41.   while (ReadLn(line,255)) {
  42.     if (!found && sscanf(line,"ERROR: %[^\n]",msg->errStr) == 1)
  43.       found = TRUE;
  44.     else if (!found && sscanf(line,"WARNING: %[^\n]",msg->errStr) == 1) {
  45.       msg->warn = TRUE;
  46.       found = TRUE;
  47.     }
  48.     else if (found && sscanf(line," file '%[^']' line %d column %d",
  49.              msg->fileName,&msg->row,&msg->col) == 3) {
  50.       return(TRUE);
  51.     }
  52.     else if (found && sscanf(line," file '%[^']' line %d",msg->fileName,&msg->row) == 2) {
  53.       return(TRUE);
  54.     }
  55.     else if (found && sscanf(line," file '%[^']'",msg->fileName) == 1) {
  56.       msg->row = 1;
  57.       return(TRUE);
  58.     }
  59.   }
  60.   return(FALSE);
  61. }
  62.  
  63.  
  64. int
  65. main(int argc,UBYTE *argv[])
  66. {
  67. struct ErrorMsg errMsg;
  68.  
  69.   while (ConvertMsg(&errMsg))
  70.     PrintMsg(&errMsg);
  71.  
  72.   return(0);
  73. }
  74.  
  75.